﻿//-----------------------------------------------------------------------
// <copyright file="CarInfo.aspx.cs" company="CMSN Software">
//    Copyright © 2010  CMSN Software
//    This program is free software: you can redistribute it and/or modify
//    it under the terms of the GNU General Public License as published by
//    the Free Software Foundation, either version 3 of the License, or
//    (at your option) any later version.
//
//    This program is distributed in the hope that it will be useful,
//    but WITHOUT ANY WARRANTY; without even the implied warranty of
//    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//    GNU General Public License for more details.
//
//    You should have received a copy of the GNU General Public License
//    along with this program.  If not, see http://www.gnu.org/licenses.
// </copyright>
//-----------------------------------------------------------------------
        
namespace CMSNSoftwareTutorials.ChangeTheUrlInAjaxApplications
{
    using System;

    /// <summary>
    /// code behind of the CarInfo.aspx. this will return details of the given car
    /// </summary>
    public partial class CarInfo : System.Web.UI.Page
    {
        /// <summary>
        /// Handles the Load event of the Page control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        protected void Page_Load(object sender, EventArgs e)
        {
            int carId = 0;
            if (int.TryParse(Request.Params["CarId"], out carId))
            {
                Car selecterCar = CarStore.CarInformation(carId);
                string carInformation = string.Empty;
                carInformation += "<div class='car-information'>";
                carInformation += "<div>" + selecterCar.Make + "</div>";
                carInformation += "<div>" + selecterCar.Model + "</div>";
                carInformation += "<div>" + selecterCar.Year + "</div>";
                carInformation += "<div>" + selecterCar.Doors + "</div>";
                carInformation += "<div>" + selecterCar.Color + "</div>";
                carInformation += "<div>" + selecterCar.Price + "</div>";
                carInformation += "</div>";
                this.CarInformationContainer.Text = carInformation;
            }
        }
    }
}